
for(REFERENCE_PATH,REFERENCES) {

	REFERENCE_TARGET = $$basename(REFERENCE_PATH)
	REFERENCE_PROJECT = $$OUT_PWD/$$REFERENCE_PATH/$${REFERENCE_TARGET}.pro

	## INTERFACES
	REFERENCE_HEADERS = $$fromfile($$REFERENCE_PROJECT, HEADERS)
	for(REFERENCE_HEADER,REFERENCE_HEADERS) {

	   REFERENCE_HEADER = $$files($$OUT_PWD/$$REFERENCE_PATH/$$REFERENCE_HEADER)
	   win32: REFERENCE_HEADER ~= s,/,\\,g
	   win32: !isEmpty(REFERENCE_HEADER): REFERENCE_HEADER_CONTENT = $$system(TYPE $$REFERENCE_HEADER)
	   else:  !isEmpty(REFERENCE_HEADER): REFERENCE_HEADER_CONTENT = $$system(cat $$REFERENCE_HEADER)
	   REFERENCE_HEADER_CONTENT = $$find(REFERENCE_HEADER_CONTENT, Q_DECLARE_INTERFACE)
	   !isEmpty(REFERENCE_HEADER_CONTENT): REFERENCE_INTERFACES += $$REFERENCE_HEADER
	   else : REFERENCE_INTERFACES =
	}

	!isEmpty(REFERENCE_INTERFACES) : CONFIG(plugin) {
	   message(<$$REFERENCE_TARGET> interfaces included in <$$TARGET> )
	   HEADERS += $$REFERENCE_INTERFACES
	   INCLUDEPATH += $$files($$OUT_PWD/$$REFERENCE_PATH)
	   DEPENDPATH += $$files($$OUT_PWD/$$REFERENCE_PATH)
	   DEFINES += $${REFERENCE_TARGET}_PLUGIN
	} else {
		REFERENCE_LIBRARY = $${REFERENCE_TARGET} $$lower($$REFERENCE_TARGET)
	}

	## BINARIES
	for(REFERENCE_HEADER,REFERENCE_LIBRARY) {
	   REFERENCE_HEADER = $$files($$OUT_PWD/$$REFERENCE_PATH/$${REFERENCE_HEADER}.h)
	   win32: REFERENCE_HEADER ~= s,/,\\,g
	   !isEmpty(REFERENCE_HEADER):exists($$REFERENCE_HEADER): REFERENCE_BINARIES += $$REFERENCE_HEADER
	   else : REFERENCE_BINARIES =
	}

	!isEmpty(REFERENCE_BINARIES) {
	   message(<$$REFERENCE_TARGET> linked in <$$TARGET>)
	   HEADERS += $$REFERENCE_BINARIES
	   INCLUDEPATH += $$files($$OUT_PWD/$$REFERENCE_PATH)
	   DEPENDPATH += $$files($$OUT_PWD/$$REFERENCE_PATH)
	   DEFINES += $${REFERENCE_TARGET}_IMPORT
	   QT += $$fromfile($$REFERENCE_PROJECT, QT)


	   ## LINK
	   win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/$$REFERENCE_PATH/release/ -l$$REFERENCE_TARGET
	   else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/$$REFERENCE_PATH/debug/ -l$$REFERENCE_TARGET
	   else:symbian: LIBS += -l$$REFERENCE_TARGET
	   else:unix: LIBS += -L$$OUT_PWD/$$REFERENCE_PATH/ -l$$REFERENCE_TARGET

	   ## DEPENDENCIES
	   TARGET.depends += $$REFERENCE_TARGET

	   ## LOCAL COPY
	   CONFIG(debug, debug|release): REFERENCE_TYPES = dll lib pdb exp
	   CONFIG(release, debug|release): REFERENCE_TYPES = dll lib
	   for(REFERENCE_TYPE,REFERENCE_TYPES) {
		  CONFIG(debug, debug|release): IMPORTS += $$OUT_PWD/$$REFERENCE_PATH/debug/$${REFERENCE_TARGET}.$$REFERENCE_TYPE
		  CONFIG(release, debug|release): IMPORTS += $$OUT_PWD/$$REFERENCE_PATH/release/$${REFERENCE_TARGET}.$$REFERENCE_TYPE
	   }
	}
}


for(IMPORT_PATH,IMPORTS) {
	win32: IMPORT_PATH ~= s,/,\\,g
	CONFIG(debug, debug|release): QMAKE_PRE_LINK += $$quote($${QMAKE_COPY} $$IMPORT_PATH debug) &
	CONFIG(release, debug|release): QMAKE_PRE_LINK += $$quote($${QMAKE_COPY} $$IMPORT_PATH release) &
}
